package cn.clq.ymcc.feign;

import cn.clq.ymcc.doc.CourseDoc;
import cn.clq.ymcc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author clqlongbao
 * @version 1.0
 * @description: TODO
 * @date 2022/7/25 14:58
 */
@Component
public class CourseSearchFeignClientFallBackFactory implements FallbackFactory<CourseSearchFeignClient> {
    @Override
    public CourseSearchFeignClient create(Throwable throwable) {
        return new CourseSearchFeignClient() {
            @Override
            public JSONResult saveCourse(CourseDoc courseDoc) {
                throwable.printStackTrace();
                return JSONResult.error("搜索服务不可达(新增)");
            }

            @Override
            public JSONResult deleteCourse(CourseDoc courseDoc) {
                throwable.printStackTrace();
                return JSONResult.error("搜索服务不可达(删除)");
            }
        };
    }
}
